//
//  HOTProfileReviewViewController.m
//  Genpara
//
//  Created by AndyChang.zhang on 14-9-12.
//  Copyright (c) 2014年 zhangchh. All rights reserved.
//

#import "HOTFreeInfoViewController.h"
#import "HOTProfileModel.h"
#import "HOTEvaluationViewController.h"
#import "HOTSendMessageViewController.h"
#import "HOTProfileReviewViewController.h"
#import "HOTMessageChatViewController.h"
#import "HOTCostPopupHandler.h"

@interface HOTFreeInfoViewController () {
    
    NSDictionary *_freeInfo;
}

@end

@implementation HOTFreeInfoViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil freeInfo:(NSDictionary *)freeInfo
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        _freeInfo = freeInfo;
    }
    return self;
}

-(void)viewDidAppear:(BOOL)animated {
    
    [super viewDidAppear:animated];
    
    //_mainScrollView.contentSize = CGSizeMake(_mainScrollView.frame.size.width, ZZZ_calcY(_mainScrollView, 40));
    
    //contentScrollView.contentSize = CGSizeMake(contentScrollView.frame.size.width, ZZZ_calcY(_contentLabel, 20));
    
    
    //contentScrollView.layer.borderColor
    //CGSize size = [contentScrollView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
    
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    [self setNaviTitle:@"空き情報"];
    
    self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg_genba"]];
    
    _nickNameLab.text = [HOTUtils getString:[_freeInfo objectForKey:@"user_name"]];
    
    _sexLabel.text = [self.userInfo sexNameWithId:[HOTUtils getString:[_freeInfo objectForKey:@"user_sex"]]];
    
    _birthdayLabel.text = [self.userInfo jobNameWithId:[HOTUtils getString:[_freeInfo objectForKey:@"job_id"]] jobName:[HOTUtils getString:[_freeInfo objectForKey:@"job_name"]]];
    
    _contentLabel.text = [_freeInfo objectForKey:@"self_intro"];
    
    _workPlaceLabel.text = [NSString stringWithFormat:@"%@、%@",
                            [self.userInfo cityNameWithId:[_freeInfo objectForKey:@"city_id"] ],
                            [_freeInfo objectForKey:@"district"]];
    
    NSString *workerSum = [_freeInfo objectForKey:@"worker_sum"];
    int workers = 0;
    if ([HOTUtils isNotNullOrEmpty:workerSum]) {
        
        workers = [workerSum intValue];
    }
    if (workers >= 10) {
        _workerNumLabel.text = [NSString stringWithFormat:@"%@人以上",[_freeInfo objectForKey:@"worker_sum"]];
    } else {
        _workerNumLabel.text = [NSString stringWithFormat:@"%@人",[_freeInfo objectForKey:@"worker_sum"]];
    }
    
    NSString *startDate = [HOTUtils getString:[_freeInfo objectForKey:@"work_start_time"]];
    
    NSString *endDate = [HOTUtils getString:[_freeInfo objectForKey:@"work_end_time"]];
    
    
    _freeDateLabel.text = [NSString stringWithFormat:@"%@〜%@",startDate, endDate];
}

-(void)initView {
    
    
}



- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)sendMessageBtnClicked:(id)sender {
    
    __unsafe_unretained HOTFreeInfoViewController *tempObj = self;
    [[HOTCostPopupHandler costPopupHandler] showWithPopupStyle:HOTCostPopupStyle2
                                                      userInfo:nil
                                                        cancel:nil
                                                       confirm:^{
                                                           
                                                           HOTMessageChatViewController *mcvc = [[HOTMessageChatViewController alloc] initWithNibName:@"HOTMessageChatViewController" bundle:nil conv_type:CONV_TYPE_GENBA target_uid:[_freeInfo objectForKey:@"user_id"]];
                                                           
                                                           
                                                           [tempObj.navigationController pushViewController:mcvc animated:YES];
                                                       }];
    
    

}

- (IBAction)profileBtnClicked:(id)sender {
    
    __unsafe_unretained HOTFreeInfoViewController *tempObj = self;
    [[HOTCostPopupHandler costPopupHandler] showWithPopupStyle:HOTCostPopupStyle1
                                                      userInfo:nil
                                                        cancel:nil confirm:^{
        
        HOTProfileReviewViewController *prvc = [[HOTProfileReviewViewController alloc] initWithNibName:@"HOTProfileReviewViewController" bundle:nil userInfo:nil targetUserId:[_freeInfo objectForKey:@"user_id"]];
        [tempObj.navigationController pushViewController:prvc animated:YES];
    }];
}

@end
